<?php
$this->breadcrumbs=array();

if (strtolower(Yii::app()->language) == 'fi_fi') {
	$this->pageTitle = 'Yamii - Tarjoustutkasi';
	$postfix = 'fin';
	$alt1 = 'Varaa tämä tarjous myöhempää käyttöä varten';
	$alt2 = 'Skannaa QR-koodin paikan päällä saadakseen tarjouksen';
	$alt3 = 'Näytä leima lunastaa tarjouksen';
} else {
	$this->pageTitle = 'Yamii - Your Deal Radar';
	$postfix = 'eng';
	$alt1 = 'reserve an offer';
	$alt2 = 'scan the barcode';
	$alt3 = 'show the stamp to redeem the offer';
}
?>
<div style="margin:10px;">
	<p style="color:#333;"><?php echo BUtils::T('subscribe_windows_app_lbl'); ?></p>
	<form id="win_subscribe_form" action="<?php echo Yii::app()->createUrl('/app/windows?subscribe=1'); ?>" method="post">
		<input class="enablewatermake" type="text" id="txt_email" name="txt_email" placeholder="<?php echo BUtils::T('email_enter_lbl'); ?>" />
		<br />
		<input type="submit" value="<?php echo BUtils::T('confirm_btn'); ?>" class="btn btn btn-danger" style="margin-right:10px;">
		<a href="javascript:history.go(-1);"><?php echo BUtils::T('back_btn'); ?></a>
		<span class="loading_message" style="display:none;"><img src="<?php echo Yii::app()->baseUrl; ?>/img/loader.gif" alt="" /></span>
		<div class="message_box" style="margin-top:12px;">
			<span class="error_message" style="color:red;"></span>
			<span class="success_message" style="color:green;"></span>
		</div>
	</form>
</div>
<script>
$(function() {
	$('#win_subscribe_form').on('submit', function() {
		$.ajax({
			type: 'POST', url: $(this).attr('action'),
			cache: false, data: $(this).serialize(),
			error: function(obj) {
				$('#win_subscribe_form .loading_message').hide();
				$('#win_subscribe_form .success_message').html('').hide();
				$('#win_subscribe_form .error_message').html('Network error!').show();
			},
			beforeSend: function(obj) {
				$('#win_subscribe_form .loading_message').show();
				$('#win_subscribe_form .success_message').html('').hide();
				$('#win_subscribe_form .error_message').html('').hide();
			},
			success: function(data) {
				$('#win_subscribe_form .loading_message').hide();
				var json = jQuery.parseJSON(data);
				if (json.code == 200) {
					$('#win_subscribe_form .error_message').html('').hide();
					$('#win_subscribe_form .success_message').html(json.message).show();
				} else {
					$('#win_subscribe_form .success_message').html('').hide();
					$('#win_subscribe_form .error_message').html(json.message).show();
				}
			}
		});
		return false;
	});
});
</script>